#include <func.h>

void* start_routine(void* arg) {
    sleep(1);
    printf("tid: %ld\n", pthread_self());
    // ...
    pthread_exit((void*)9527);
}

int main(int argc, char* argv[])
{
    // 创建线程
    pthread_t tid;
    int err = pthread_create(&tid, NULL, start_routine, NULL);
    if (err) {
        error(1, err, "pthread_create()");
    }
    pthread_detach(tid);
    
    int retval;
    err = pthread_join(tid, (void**)&retval);
    if (err) {
        error(0, err, "pthread_join %lx", tid);
    }
    printf("main thread: %d\n", retval);
    return 0;
}

